package com.shire.shire_interface.service.account.impl;

import com.shire.shire_interface.common.utils.AppRandomUtils;
import com.shire.shire_interface.common.utils.KeyValue;
import com.shire.shire_interface.common.utils.StrUtils;
import com.shire.shire_interface.constants.DeviceCode;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class DeviceCodeService {
    @Resource
    private IphoneSetService iphoneSetService;

    public void genByRandom(DeviceCode deviceCode){
        // 获取手机版本信息
//		IphoneInfo iphoneInfo = iphoneInfoService.getRandomInfo(deviceInfo);
        IphoneParameter iphoneInfo = iphoneSetService.getRandomParameter(StrUtils.getBlankStr(deviceCode.iphone_cfg, "default"));
        if(deviceCode.dev_type_name.equals("iphone5s")) {
            iphoneInfo = new IphoneParameter("ex_iphone5s", "iPhone6,1", "11.4", "A1453", "15F79");
        }
        deviceCode.platform = iphoneInfo.getPlatform();//codeDicService.getDicValue("platform");
        deviceCode.osversion = iphoneInfo.getOsversion();//codeDicService.getDicValue("osversion");
        deviceCode.Model = iphoneInfo.getModel();//codeDicService.getDicValue("Model");
        deviceCode.BuildVersion = iphoneInfo.getBuildVersion();//codeDicService.getDicValue("BuildVersion");
        deviceCode.dev_type_name = iphoneInfo.getName(); // 型号名称，小写
        // 随机
        deviceCode.wifiMac = AppRandomUtils.genMac(); // 48:d7:05:8c:f1:dd
        deviceCode.bluetooth = AppRandomUtils.genNextMac(deviceCode.wifiMac); // 48:d7:05:8c:f1:de
        deviceCode.mac = AppRandomUtils.genNextMac(deviceCode.bluetooth); // 48:d7:05:8c:f1:df
        deviceCode.serial_num = AppRandomUtils.genSerialNum(deviceCode.dev_type_name);//AppRandomUtils.genSerialNum();
        deviceCode.imei = AppRandomUtils.genImei();
        deviceCode.unique_chip_id = AppRandomUtils.genUniqueChipId_wiki();//AppRandomUtils.genUniqueChipId();
        deviceCode.udid = AppRandomUtils.genUdid(deviceCode.serial_num, deviceCode.unique_chip_id, deviceCode.wifiMac, deviceCode.bluetooth);
        deviceCode.mlb = AppRandomUtils.genMlb();

        deviceCode.idfa = AppRandomUtils.genIdfa();
        deviceCode.uuid = AppRandomUtils.genUuid();
        deviceCode.battery_id = AppRandomUtils.genBatteryId();
        deviceCode.inverse_deviceid = AppRandomUtils.genInverseDeviceid();
        deviceCode.dieid = AppRandomUtils.getRandomNum(19);
        deviceCode.iop_serial_num = AppRandomUtils.genSerialNum(deviceCode.dev_type_name);

        deviceCode.idfv = AppRandomUtils.genUuid();
        KeyValue<String, Integer> mobileKv = AppRandomUtils.genMobileNo();
        deviceCode.telnum = mobileKv.getKey();
        deviceCode.carrier = "" + mobileKv.getValue();
        deviceCode.phoneName = AppRandomUtils.getChineseName()+ "的 iPhone";
        deviceCode.wifiIP = AppRandomUtils.genWifiIp();
        deviceCode.wifiSSID = AppRandomUtils.genWifiSSID();
        deviceCode.WirelessBoardSN = AppRandomUtils.getRandomHex(12);
        deviceCode.iccid = AppRandomUtils.getRandomNum(20);
        deviceCode.imsi = AppRandomUtils.getRandomNum(15);
    }
}
